﻿/*
 * Copyright (C) 2011 Kamran Zafar
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of
 * this software and associated documentation files (the "Software"), to deal in
 * the Software without restriction, including without limitation the rights to
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
 * of the Software, and to permit persons to whom the Software is furnished to do
 * so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 * 
 * */
 
/*
 * Created by SharpDevelop.
 * User: Kamran
 * Date: 19/01/2010
 * Time: 18:16
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.IO;
using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace org.kamranzafar.hotfusion
{
	/// <summary>
	/// Description of DestinationPaths.
	/// </summary>
	public class DestinationPath
	{
		private static List<DestPathInfo> paths=new List<DestPathInfo>();
		
		public static List<DestPathInfo> Paths {
			get { return paths; }
		}
		
		static DestinationPath(){
			paths.Add(new DestPathInfo("ApplicationData", "Application Data"));
			paths.Add(new DestPathInfo("Desktop", "Desktop"));
			paths.Add(new DestPathInfo("Favorites", "Favorites"));
			paths.Add(new DestPathInfo("Host", "Extractor directory"));
			paths.Add(new DestPathInfo("Personal", "User documents"));
			paths.Add(new DestPathInfo("ProgramFiles", "Program install directory"));
			paths.Add(new DestPathInfo("SendTo", "Send To"));
			paths.Add(new DestPathInfo("Startup", "Startup programs"));
			paths.Add(new DestPathInfo("System", "System directory (e.g. system32)"));
			paths.Add(new DestPathInfo("Temp", "Temporary files directory"));
			paths.Add(new DestPathInfo("Windows", "System root directory"));
		}
		
		public static string getSpecialPath(string path){
			path = fixPath(path);
			
			for(int i=0;i<paths.Count;i++){
				if(path.ToLower().StartsWith("{"+paths[i].Path.ToLower()+@"}\"))
					return paths[i].Path;
			}
			
			return null;
		}
		
		public static bool isSpecialPath(String path){
			return (getSpecialPath(path)!=null) ? true : false;
		}
		
		private static string fixPath(string path){
			return Regex.Replace(path, @"\\{2,}", @"\").Replace("/", @"\");
		}
		
		public class DestPathInfo{
			private string path;
			public string Path {
				get { return path; }
				set { path = value; }
			}

			private string description;
			public string Description {
				get { return description; }
				set { description = value; }
			}
			
			public DestPathInfo(string path, string description){
				this.path=path;
				this.description=description;
			}
			
			public override string ToString(){
				return path;
			}
		}
	}
}
